package com.pago.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import com.pago.beans.catalogos.Beca;

public class BecaDaoImpl implements IBecaDao {


	private JdbcTemplate jdbcTemplate;

	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}
	public BecaDaoImpl() {
		// TODO Auto-generated constructor stub
	}

	public List<Beca> getBecasList(){
		// TODO Auto-generated method stub
		return getJdbcTemplate().query(
				"select * from caja.cata_beca", new RowMapper<Beca>() {        	
					public Beca mapRow(ResultSet  rs, int arg1)
							throws SQLException {
						
						
						Beca beca=new Beca();
						beca.setCveBeca(rs.getInt("cve_beca"));
						beca.setDescBeca(rs.getString("desc_beca"));
						beca.setPorcBeca(rs.getDouble("porc_beca"));
						System.out.println(beca.getDescBeca());
						
						return beca;					
					}					
				});
	}

	public JdbcTemplate getJdbcTemplate(){
		return this.jdbcTemplate;
	}
	@Override
	public int insertBeca(Beca beca) {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public int updateBeca(Beca beca) {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public int deleteBeca(Beca beca) {
		// TODO Auto-generated method stub
		return 0;
	}

}
